<?php

namespace app\admin\controller\advertiser;

use app\admin\service\advertiser\AdvertiserSecondaryService as AdvertiserPageService;
use app\BaseController;
use think\facade\Request;
use think\response\Json;

class AdvertiserSecondary extends BaseController
{
    /**
     * 页面广告位列表
     * @param AdvertiserPageService $advertiserPageService
     * @return Json
     */
    public function pageList(AdvertiserPageService $advertiserPageService): Json
    {
        $params['page'] = Request::param('page/d', 1);
        $params['limit'] = Request::param('limit/d', 10);
        $params['code'] = Request::param('code/s');
        $params['name'] = Request::param('name/s');
        $params['status'] = Request::param('status/d');
        $params['sort'] = Request::param('sort/d', 99);
        return $advertiserPageService->pageList($params);
    }

    /**
     * 页面广告位添加
     * @param AdvertiserPageService $advertiserPageService
     * @return Json
     */
    public function pageAdd(AdvertiserPageService $advertiserPageService): Json
    {
        $params['name'] = Request::param('name/s');
        $params['img'] = Request::param('img/s');
        $params['status'] = Request::param('status/d', 1);
        $params['sort'] = Request::param('sort/d', 99);
        return $advertiserPageService->pageAdd($params);
    }

    /**
     * 页面广告位编辑
     * @param AdvertiserPageService $advertiserPageService
     * @return Json
     */
    public function pageEdit(AdvertiserPageService $advertiserPageService): Json
    {
        $params['id'] = Request::param('id/d');
        $params['name'] = Request::param('name/s');
        $params['img'] = Request::param('img/s');
        $params['status'] = Request::param('status/d', 1);
        $params['sort'] = Request::param('sort/d', 99);
        return $advertiserPageService->pageEdit($params);
    }

    /**
     * 页面广告位删除
     * @param AdvertiserPageService $advertiserPageService
     * @return Json
     */
    public function pageDel(AdvertiserPageService $advertiserPageService): Json
    {
        $params['id'] = Request::param('id/d');
        return $advertiserPageService->pageDel($params);
    }
}